﻿{include file="public/header" /}
{css href="__ROOT__/static/public/umeditor/themes/default/css/umeditor.css" /}
{js href="__ROOT__/static/public/umeditor/third-party/template.min.js" /}
{js href="__ROOT__/static/public/umeditor/umeditor.config.js" /}
{js href="__ROOT__/static/public/umeditor/umeditor.min.js" /}
	<form method="post" class="form-x" action="{if $data.id}?id={$data.id}{/if}">
	<div class="panel admin-panel">
		<div class="panel-head"><strong>{:lang('currency')['edit']}</strong></div>
		<br/>
		<script>
		//city 参数和回调
		var gid="{$data.gid}";
		var cateid="{$data.cateid}";
		var selectc=true;
		function select_g(){
			return false;
		}
		function select_c(){
			return false;
		}
		</script>
		<div class="form-group">
			<div class="label">
				<label for="title">{:lang('label')['category']}</label>
			</div>
			<div class="field">
				{include file="public/category" /}
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="title">{:lang('label')['title']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="title" name="title" value="{$data.title}" size="80" placeholder="{:lang('label')['title']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="stock">{:lang('label')['stock']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="stock" name="stock" value="{$data.stock}" size="80" placeholder="{:lang('label')['stock']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="price">{:lang('label')['price']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="price" name="price" value="{$data.price}" size="24" placeholder="{:lang('label')['price0']}" data-validate="required:{:lang('currency')['required']}" />
				<input type="text" class="input input-auto" id="price1" name="price1" value="{$data.price1}" size="24" placeholder="{:lang('label')['price1']}" data-validate="required:{:lang('currency')['required']}" />
				<input type="text" class="input input-auto" id="price2" name="price2" value="{$data.price2}" size="24" placeholder="{:lang('label')['price2']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>{:lang('label')['spec']}</label>
			</div>
			<div class="field">
			{if $data.spec}
			{volist name="data.spec" id="spec"}
			<div>
				<input type="text" class="input input-auto" name="spec[{$i-1}][title]" size="30" value="{$spec.title}" placeholder="{:lang(\'label\')[\'spec\']}"  />
				<input type="text" class="input input-auto" name="spec[{$i-1}][price0]" size="10" value="{$spec.price0}" placeholder="{:lang(\'label\')[\'price0\']}" />
				<input type="text" class="input input-auto" name="spec[{$i-1}][price1]" size="10" value="{$spec.price1}" placeholder="{:lang(\'label\')[\'price1\']}" />
				<input type="text" class="input input-auto" name="spec[{$i-1}][price2]" size="10" value="{$spec.price2}" placeholder="{:lang(\'label\')[\'price2\']}" />
				<input type="number" class="input input-auto" name="spec[{$i-1}][stock]" size="10" value="{$spec.stock}" placeholder="{:lang(\'label\')[\'stock\']}" />
				{if $i == 1}
				<button type="button" class="button addspec">+</button>
				{else}
				<button type="button" class="button delspec">-</button>
				{/if}
			</div>
			{/volist}
			{else}
			<div>
				<input type="text" class="input input-auto" name="spec[0][title]" size="30" placeholder="{:lang(\'label\')[\'spec\']}"  />
				<input type="text" class="input input-auto" name="spec[0][price0]" size="10" placeholder="{:lang(\'label\')[\'price0\']}" />
				<input type="text" class="input input-auto" name="spec[0][price1]" size="10" placeholder="{:lang(\'label\')[\'price1\']}" />
				<input type="text" class="input input-auto" name="spec[0][price2]" size="10" placeholder="{:lang(\'label\')[\'price2\']}" />
				<input type="number" class="input input-auto" name="spec[0][stock]" size="10" placeholder="{:lang(\'label\')[\'stock\']}" />
				<button type="button" class="button addspec">+</button>
			</div>
			{/if}
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="attr">{:lang('label')['attr']}</label>
			</div>
			<div class="field">
				{if $data.spec}
				{volist name="data.attr" id="attr"}
				<div>
					<input type="text" class="input input-auto" id="attr" name="attr[]" value="{$attr}" size="20" placeholder="{:lang('label')['attr']}" />
					{if $i == 1}
					<button type="button" class="button addattr">+</button>
					{else}
					<button type="button" class="button delspec">-</button>
					{/if}
				</div>
				{/volist}
				{else}
				<div>
					<input type="text" class="input input-auto" id="attr" name="attr[]" size="20" placeholder="{:lang('label')['attr']}" />
					<button type="button" class="button addattr">+</button>
				</div>
				{/if}
			</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image1">{:lang('label')['image']}1</label>
			</div>
			<div class="field">
				<input type="text" readonly class="input input-auto" id="image1" name="image1" value="{$data.image1}" size="65" placeholder="{:lang('label')['image']}" data-validate="required:{:lang('currency')['required']}" />
				<span class="addbtn"><button type="button" data-id="image1" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image2">{:lang('label')['image']}2</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image2" name="image2" value="{$data.image2}" size="65" placeholder="{:lang('label')['image']}" />
				<span class="addbtn"><button type="button" data-id="image2" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image3">{:lang('label')['image']}3</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image3" name="image3" value="{$data.image3}" size="65" placeholder="{:lang('label')['image']}" />
				<span class="addbtn"><button type="button" data-id="image3" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
		<div class="input-inline clearfix">
			<div class="label">
				<label for="image4">{:lang('label')['image']}4</label>
			</div>
			<div class="field">
				<input type="text" readonly onclick="$(this).val('')" class="input input-auto" id="image4" name="image4" value="{$data.image4}" size="65" placeholder="{:lang('label')['image']}" />
				<span class="addbtn"><button type="button" data-id="image4" class="button upload">{:lang('form')['file']}</button></span>
			</div>
		</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label>{:lang('label')['status']}</label>
			</div>
			<div class="field">
				<div class="button-group button-group-small radio">
					<label class="button {if $data.status == "1" || !$data.status}active{/if}"><input name="status" value="1" {if $data.status == "1" || !$data.status}checked="checked"{/if} type="radio"><span class="icon icon-check"></span> {:lang('currency')['status_1']}</label>
					<label class="button {if $data.status == "2"}active{/if}"><input name="status" value="2" {if $data.status == "2"}checked="checked"{/if} type="radio"><span class="icon icon-times"></span> {:lang('currency')['status_2']}</label>
					<!-- <label class="button {if $data.status == "3"}active{/if}"><input name="status" value="3" {if $data.status == "3"}checked="checked"{/if} type="radio"><span class="icon icon-times"></span> {:lang('currency')['status_3']}</label>
					<label class="button {if $data.status == "4"}active{/if}"><input name="status" value="4" {if $data.status == "4"}checked="checked"{/if} type="radio"><span class="icon icon-times"></span> {:lang('currency')['status_4']}</label> -->
				</div>
			</div>
		</div>
		<!-- <div class="form-group">
			<div class="label">
				<label for="service">{:lang('label')['service']}</label>
			</div>
			<div class="field">
				<textarea name="service" class="input input-auto" rows="5" cols="80" placeholder="{:lang('service')}" data-validate="required:{:lang('required')}">{$data.service}</textarea>
			</div>
		</div> -->
		<div class="form-group">
			<div class="label">
				<label>{:lang('label')['content']}</label>
			</div>
			<div class="field">
				<script data-validate="required:{:lang('currency')['required']}" type="text/plain" name="content" id="myEditor" style="width:1000px;height:240px;">{$data.content} </script>
			</div>
		</div>
		<div id="refuse" class="form-group{if $data.status != '4'} hidden {/if}">
			<div class="label">
				<label for="refuse">{:lang('label')['refuse']}</label>
			</div>
			<div class="field">
				<textarea name="refuse" class="input input-auto" rows="5" cols="80" placeholder="{:lang('label')['refuse']}" >{$data.refuse}</textarea>
			</div>
		</div>
		<div class="form-button">
			<button class="button bg-main" type="submit">{:lang('form')['submit']}</button>
		</div>
		<br/>
		</div>
	</form>
		<script>
		$("[name='status']").click(function(){
			var status = $("[name='status']:checked").val();
			if(status=='4'){
				$("#refuse").removeClass('hidden');
			}else{
				$("#refuse").addClass('hidden');
			}
		});
		$(".addspec").click(function(){
			var num = $(this).parent().parent().find("div").length;
			var html = '<div><input type="text" class="input input-auto" name="spec['+num+'][title]" size="30" placeholder="{:lang(\'label\')[\'spec\']}"  /> <input type="text" class="input input-auto" name="spec['+num+'][price0]" size="10" placeholder="{:lang(\'label\')[\'price0\']}" /> <input type="text" class="input input-auto" name="spec['+num+'][price1]" size="10" placeholder="{:lang(\'label\')[\'price1\']}" /> <input type="text" class="input input-auto" name="spec['+num+'][price2]" size="10" placeholder="{:lang(\'label\')[\'price2\']}" /> <input type="number" class="input input-auto" name="spec['+num+'][stock]" size="10" placeholder="{:lang(\'label\')[\'stock\']}" /> <button type="button" class="button delspec">-</button></div>';
			$(this).parent().parent().append(html);
		});
		$(".addattr").click(function(){
			var html = '<div><input type="text" class="input input-auto" id="attr" name="attr[]" size="20" placeholder="{:lang(\'label\')[\'attr\']}"/> <button type="button" class="button delspec">-</button></div>';
			$(this).parent().parent().append(html);
		});
		$(document).on("click",".delspec",function(){
			$(this).parent().remove();
		})
		var um = UM.getEditor('myEditor');
	</script>
{include file="public/footer" /}